package com.gosuncn.tools;


import java.util.HashMap;
import java.util.Map;


/**
 *功能描述   消息组类
 * @author zxl
 * @date 2021/7/26
*/
public class R {
    private boolean success;
    private Integer code;
    private String message;
    private Map<String,Object> data = new HashMap<>();
//


    /***
     *构造方法
    */
    public R() { }

    /***
     *成功提示
     */
   public static R ok(){
       R r = new R();
       r.setSuccess(ResultCodeEnum.SUCCESS.getSuccess());
       r.setCode(ResultCodeEnum.SUCCESS.getCode());
       r.setMessage(ResultCodeEnum.SUCCESS.getMessage());
       return r;

   }

    /***
     *失败提示
     */
    public static R error(){
        R r = new R();
        r.setSuccess(ResultCodeEnum.FAIL.getSuccess());
        r.setCode(ResultCodeEnum.FAIL.getCode());
        r.setMessage(ResultCodeEnum.FAIL.getMessage());
        return r;
    }

    public R message(String message){
        this.setMessage(message);
        return this;
    }
    public R data(String key, Object value){
        this.data.put(key,value);
        return  this;
    }


    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }




}
